﻿using Appliaction.Dto.Pinv;
using Appliaction.IAppServices.IVendorService;
using AutoMapper;
using Domain.Entitys.Pinv;
using Domain.IRepositorys.Pinv;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Appliaction.AppServices.Pinv
{
    public class VendorService: IVendorService
    {
        private readonly IMapper mapper;
        private readonly IVendorRepository vendorRepository;

        public VendorService(IMapper mapper, IVendorRepository vendorRepository)
        {
            this.mapper = mapper;
            this.vendorRepository = vendorRepository;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="vendor"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> Pinv_VendorAdd(VendorAddDto vendor)
        {
            pinv_vendor pinv_Vendor = mapper.Map<pinv_vendor>(vendor);
            return vendorRepository.Pinv_VendorAdd(pinv_Vendor);
        }
        /// <summary>
        /// 查询总条数
        /// </summary>
        /// <param name="Vendor_name"></param>
        /// <param name="Vendor_code"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int Pinv_VendorCount(string Vendor_name, string Vendor_code)
        {
            return vendorRepository.Pinv_VendorCount(Vendor_name, Vendor_code);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="vendor"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> Pinv_VendorDelete(VendorDeleteDto vendor)
        {
            pinv_vendor pinv_Vendor = mapper.Map<pinv_vendor>(vendor);
            return vendorRepository.Pinv_VendorDelete(pinv_Vendor);
        }
        /// <summary>
        /// 分页、条件查询
        /// </summary>
        /// <param name="Vendor_name"></param>
        /// <param name="Vendor_code"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<pinv_vendor> Pinv_VendorFYWhere(string Vendor_name, string Vendor_code, int currentPage, int pageSize)
        {
            return vendorRepository.Pinv_VendorFYWhere(Vendor_name, Vendor_code, currentPage, pageSize);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="vendor"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> Pinv_VendorUpdate(VendorUpdateDto vendor)
        {
            pinv_vendor pinv_Vendor = mapper.Map<pinv_vendor>(vendor);
            return vendorRepository.Pinv_VendorUpdate(pinv_Vendor);
        }
        /// <summary>
        /// 条件查询供应商编号、昵称
        /// </summary>
        /// <param name="Vendor_name"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<pinv_vendor>> Pinv_VendorWhere(string Vendor_name)
        {
            return await vendorRepository.Pinv_VendorWhere(Vendor_name);
        }
    }
}
